<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
    $qname=addslashes(trim($_POST['name']));
    $qtype=addslashes(trim($_POST['qtype']));
    $sheng=addslashes(trim($_POST['sheng']));
    $shi=addslashes(trim($_POST['shi']));
    $qu=addslashes(trim($_POST['qu']));
    
    $shengname=addslashes(trim($_POST['shengname']));
    $shiname=addslashes(trim($_POST['cityname']));
    $quname=addslashes(trim($_POST['quname']));
    

    $query=$mysqli->query("SELECT id FROM qdui where openid='".$openid."'   limit 0,1 ");
    if($query->num_rows>0){
        echo json_encode(array('s'=>'n', 'e'=>'has'));
        exit;
    }else{
        $query=$mysqli->query("SELECT id FROM qdui where name='".$qname."'  limit 0,1 ");
        if($query->num_rows>0){
          echo json_encode(array('s'=>'n', 'e'=>'name'));
          exit;
        }
        $mysqli->query("insert into qdui(openid,name,qtype,sheng,shi,qu,shengname,shiname,quname,createtime) values('".$openid."','".$qname."','".$qtype."','".$sheng."','".$shi."','".$qu."','".$shengname."','".$shiname."','".$quname."','".date("Y-m-d H:i:s")."')  ");
        $mysqli->query("insert into qdui_log(openid,name,qtype,sheng,shi,qu,shengname,shiname,quname,createtime) values('".$openid."','".$qname."','".$qtype."','".$sheng."','".$shi."','".$qu."','".$shengname."','".$shiname."','".$quname."','".date("Y-m-d H:i:s")."')  ");
        echo json_encode(array('s'=>'y'));
    }
    $mysqli->close();
    
    
}

